package com.itheima.mapper;

import com.itheima.pojo.Member;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface MemberMapper {
    /**
     * 根据身份证号查询会员信息
     * @param idCard
     * @return
     */
    @Select("select id, fileNumber, name, sex, idCard, phoneNumber, regTime, password, email, birthday, remark" +
            " from t_member where idCard = #{idCard}")
    Member selectByIDCard(String idCard);

    /**
     * 根据会员id查询会员信息
     * @param id
     * @return
     */
    @Select("select id, fileNumber, name, sex, idCard, phoneNumber, regTime, password, email, birthday, remark" +
            " from t_member where id = #{id}")
    Member selectById(Integer id);

    /**
     * 添加会员信息
     * @param member
     */
    @Insert("insert into t_member (fileNumber, name, sex, idCard, phoneNumber, regTime, password, email, birthday, remark) " +
            "VALUES (#{fileNumber},#{name},#{sex},#{idCard},#{phoneNumber},#{regTime},#{password},#{email},#{birthday},#{remark})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(Member member);
}
